﻿@model EyeOpen.Web.Mvc.Models.CustomerModel
@{
	const string UpdateTargetId = "async";

	var options =
		new AjaxOptions
		{
			OnComplete="parseForm();",
			HttpMethod = "Post",
			UpdateTargetId = UpdateTargetId,
			InsertionMode = InsertionMode.Replace
		};
} 

<div id="create">
@using (Ajax.BeginForm<CustomerController>(x => x.Add(null), options))
{
	<fieldset>
		<legend>Detail</legend>
		<div>      	
			@Html.HiddenFor(x => x.Id)

			@Html.FieldNameFor(x => x.Name)
			
			@Html.TextBoxFor(x => x.Name)
			@Html.ValidationMessageFor(x => x.Name)

			@Html.FieldNameFor(x => x.Acquired)
			@Html.TextBoxFor(x => x.Acquired)
			@Html.ValidationMessageFor(x => x.Acquired)

			@Html.FieldNameFor(x => x.Turnover)
			@Html.TextBoxFor(x => x.Turnover)
			@Html.ValidationMessageFor(x => x.Turnover)

			<div class="operation">
				<input type="submit" value="Save" /> <a id="cancel">Cancel</a>
			</div>
		</div>
	</fieldset>
}
</div>
<div id="@UpdateTargetId"></div>

<script type="text/javascript">
	$("#cancel").click(function () {
		$("#create").empty();
		$("@UpdateTargetId").empty();
		$("#customerList").load("/customer/list");
	});
</script>